﻿<Pages:UCViewerCore
                    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
                    xmlns:treeView="clr-namespace:Telerik.Windows.Controls.TreeView;assembly=Telerik.Windows.Controls.Navigation"
                    xmlns:Grid="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"
                    xmlns:Converter="clr-namespace:Rio.Framework.Pages.Helpers"
                    xmlns:Pages="clr-namespace:Rio.Framework.Pages.Viewer"
                    xmlns:dragAndDrop="clr-namespace:Telerik.Windows.Controls.DragDrop;assembly=Telerik.Windows.Controls"
                    xmlns:local="clr-namespace:Rio.Framework.Pages.UserControls"
                    xmlns:telerikNavigation="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation"
                    xmlns:System="clr-namespace:System;assembly=mscorlib" x:Name="ListDisplay"
                    xmlns:RioCommonControls="clr-namespace:Rio.Framework.Pages.Controls;assembly=Rio.Framework.Pages"
                    x:Class="Rio.Framework.Pages.Viewer.ListViewer"
                    mc:Ignorable="d"
                    Loaded="ListDisplay_Loaded"
                    d:DesignHeight="400"
                    d:DesignWidth="500">

    <Pages:UCViewerCore.Resources>
        <Converter:ExtractExtensionConverter x:Key="ExtractExtensionConverter" />
        <Converter:PathFileToFileNameConverterWithoutExtension x:Key="PathFileToFileNameConverterWithoutExtension" />
        <Converter:ByteArrayToBitmapImageConverter x:Key="ByteArrayToBitmapImageConverter" />
        <Converter:PathFileToFileNameConverter x:Key="PathFileToFileNameConverter" />
        <Converter:ConvertOctetsConverter x:Key="ConvertOctetsConverter" />
        <Converter:ImageRioPropertyToFriendlyDisplayConverter x:Key="ImageRioPropertyToFriendlyDisplayConverter" />
        <Converter:ImageCutedOrCopiedConverter x:Key="ImageCutedOrCopiedConverter" />
        
        <Style TargetType="treeView:TreeViewDragCue"
               x:Key="CueStyle">
            <Setter Property="DragTooltipVisibility"
                    Value="Collapsed" />
        </Style>
        <DataTemplate x:Key="DraggedItemTemplate">
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding Sender}"
                           FontWeight="Bold" />
                <TextBlock Text=", ("
                           Foreground="Gray" />
                <TextBlock Text="{Binding Subject}"
                           Foreground="Gray" />
                <TextBlock Text=")"
                           Foreground="Gray" />
            </StackPanel>
        </DataTemplate>
        <LinearGradientBrush x:Key="DropPossibleBackground"
                             StartPoint="0 0"
                             EndPoint="0 1">
            <GradientStop Offset="0"
                          Color="White" />
            <GradientStop Offset="1"
                          Color="#FFE699" />
        </LinearGradientBrush>

        <!--GridView Row-->
        <Style x:Key="CutedOrPastedRowStyle" TargetType="telerik:GridViewRow">
            <Setter Property="Foreground" Value="Red" />
            <Setter Property="dragAndDrop:RadDragAndDropManager.AllowDrag" Value="True" />
        </Style>
        <Style x:Key="DefaultRowStyle" TargetType="telerik:GridViewRow">
            <Setter Property="dragAndDrop:RadDragAndDropManager.AllowDrag" Value="True" />
        </Style>
        <Style x:Key="AlternateDefaultRowStyle" TargetType="telerik:GridViewRow">
            <Setter Property="Background" Value="#edecd8" />
            <Setter Property="dragAndDrop:RadDragAndDropManager.AllowDrag" Value="True" />
        </Style>

        <Converter:ConditionalStyleSelector x:Key="selector" ConditionConverter="{StaticResource ImageCutedOrCopiedConverter}">
            <Converter:ConditionalStyleSelector.Rules>
                <Converter:ConditionalStyleRule Style="{StaticResource CutedOrPastedRowStyle}">
                    <Converter:ConditionalStyleRule.Value>
                        <System:Boolean>True</System:Boolean>
                    </Converter:ConditionalStyleRule.Value>
                </Converter:ConditionalStyleRule>
                <Converter:ConditionalStyleRule Style="{StaticResource DefaultRowStyle}">
                    <Converter:ConditionalStyleRule.Value>
                        <System:Boolean>False</System:Boolean>
                    </Converter:ConditionalStyleRule.Value>
                </Converter:ConditionalStyleRule>
            </Converter:ConditionalStyleSelector.Rules>
        </Converter:ConditionalStyleSelector>

        <Converter:ConditionalStyleSelector x:Key="AlternateSelector" ConditionConverter="{StaticResource ImageCutedOrCopiedConverter}">
            <Converter:ConditionalStyleSelector.Rules>
                <Converter:ConditionalStyleRule Style="{StaticResource CutedOrPastedRowStyle}">
                    <Converter:ConditionalStyleRule.Value>
                        <System:Boolean>True</System:Boolean>
                    </Converter:ConditionalStyleRule.Value>
                </Converter:ConditionalStyleRule>
                <Converter:ConditionalStyleRule Style="{StaticResource AlternateDefaultRowStyle}">
                    <Converter:ConditionalStyleRule.Value>
                        <System:Boolean>False</System:Boolean>
                    </Converter:ConditionalStyleRule.Value>
                </Converter:ConditionalStyleRule>
            </Converter:ConditionalStyleSelector.Rules>
        </Converter:ConditionalStyleSelector>

    </Pages:UCViewerCore.Resources>

    <Grid x:Name="LayoutRoot" Background="White">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"
                              MinWidth="150" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*"/>

        </Grid.RowDefinitions>
        
        <RioCommonControls:DocumentContextMenu x:Name="DocumentContextMenu" ViewMode="Single"/>
        
        <!--Ribbon bar -->
        <RioCommonControls:DocumentRibbonBar x:Name="DocumentToolbar" ViewMode="List" />
        
        <!--RowStyle="{StaticResource DraggedRowStyle}"-->
        <Grid:RadGridView x:Name="GridViewDoc"
                          RowStyleSelector="{StaticResource selector}"
                          AlternateRowStyleSelector="{StaticResource AlternateSelector}" 
                          AlternationCount="2" 
                          CanUserDeleteRows="false"
                          Grid.Row="1"
                          SelectionMode="Extended"
                          RowHeight="32"
                          AutoGenerateColumns="False"
                          IsFilteringAllowed="false"
                          ShowGroupPanel="False"
                          SelectionChanged="GridViewDoc_SelectionChanged"
                          KeyUp="GridViewDoc_KeyUp"
                          Loaded="GridViewDoc_Loaded"
                          ItemsSource="{Binding Images, ElementName=ListDisplay}"
                          telerik:RadDragAndDropManager.AllowDrag="True"
                          telerik:RadDragAndDropManager.AllowDrop="True">
            <Grid:RadGridView.Columns>
                <Grid:GridViewSelectColumn x:Name="ColSelection"
                                           MinWidth="50"
                                           MaxWidth="30">
                </Grid:GridViewSelectColumn>

                <Grid:GridViewImageColumn DataMemberBinding="{Binding Converter={StaticResource ExtractExtensionConverter}}"
                                          UniqueName="TypeHeader"
                                          Header=""
                                          IsReadOnly="True"
                                          ImageStretch="None" />

                <Grid:GridViewDataColumn IsReadOnly="True"
                                         Header=""
                                         UniqueName="NameHeader" />

                <Grid:GridViewDataColumn DataMemberBinding="{Binding CreationDate}"
                                         UniqueName="CreationDateHeader"
                                         Header=""
                                         IsReadOnly="True" />

                <Grid:GridViewDataColumn DataMemberBinding="{Binding LastModificationDate}"
                                         UniqueName="LastModificationDateHeader"
                                         Header=""
                                         IsReadOnly="True" />

                <Grid:GridViewDataColumn DataMemberBinding="{Binding Dimension, ConverterParameter=Dimension, Converter={StaticResource ImageRioPropertyToFriendlyDisplayConverter}}"
                                         UniqueName="DimensionHeader"
                                         Header=""
                                         IsReadOnly="True" />

                <Grid:GridViewDataColumn DataMemberBinding="{Binding Resolution, ConverterParameter=Resolution, Converter={StaticResource ImageRioPropertyToFriendlyDisplayConverter}}"
                                         UniqueName="ResolutionHeader"
                                         Header=""
                                         IsReadOnly="True" />

                <Grid:GridViewDataColumn DataMemberBinding="{Binding NumberPages, ConverterParameter=NumberPages, Converter={StaticResource ImageRioPropertyToFriendlyDisplayConverter}}"
                                         UniqueName="NumberPagesHeader"
                                         Header=""
                                         IsReadOnly="True" />

                <Grid:GridViewDataColumn DataMemberBinding="{Binding ImageSize, Converter={StaticResource ConvertOctetsConverter}}"
                                         UniqueName="SizeHeader"
                                         Header=""
                                         IsReadOnly="True" />
            </Grid:RadGridView.Columns>

            <telerikNavigation:RadContextMenu.ContextMenu>
                <telerikNavigation:RadContextMenu>

                </telerikNavigation:RadContextMenu>
            </telerikNavigation:RadContextMenu.ContextMenu>
            
        </Grid:RadGridView>

    </Grid>
</Pages:UCViewerCore>
